package com.llg.controller;

import com.llg.model.response.DataResult;
import com.llg.model.response.PageResult;
import com.llg.model.response.ResponseResult;
import com.llg.pojo.ReceiveSpec;
import com.llg.service.ReceiveSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ReceiveSpec")
public class ReceiveSpecController {

    @Autowired
    private ReceiveSpecService service;

    //通过品牌id查找所有接收卡
    @GetMapping("/findByBrandId")
    public PageResult<ReceiveSpec> findByBrandId(Integer bid){
        return service.findByBrandId(bid);
    }

    //搜索并分页查询
    @PostMapping("/findList")
    public PageResult<ReceiveSpec> findList(Integer currentPage,Integer pageSize,@RequestBody ReceiveSpec receiveSpec){
        return service.findList(currentPage, pageSize, receiveSpec);
    }

    //通过id查找
    @GetMapping("/{id}")
    public DataResult<ReceiveSpec> findById(@PathVariable("id") Integer id){
        return service.findById(id);
    }

    //通过led型号id查找所有未与该led关联的接收卡
    @GetMapping("/findByLid")
    public PageResult<ReceiveSpec> findByLid(Integer lid){
        return service.findByLid(lid);
    }

    //增
    @PostMapping("/add")
    public DataResult<ReceiveSpec> add(@RequestBody ReceiveSpec receiveSpec){
        return service.add(receiveSpec);
    }

    //删
    @GetMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer  id){
        return service.delete(id);
    }

    //改
    @PostMapping("/update")
    public ResponseResult update(@RequestBody ReceiveSpec receiveSpec){
        return service.update(receiveSpec);
    }
}
